<template>
  <div>

    <div style="width: 400px;height: 600px;background-color: rgba(0,0,0,0.45);margin:100px auto;text-align: center;border-radius: 10px">
      <p style="font-size: 28px;font-family: '楷体';padding-top: 20px">员工需求</p>
      <hr style="width: 90%;height: 0.01px"/>
      <div style="margin-top: 20px">
        <div style="width: 100%">
          <form style="width: 100%">
            <p style="width: 100%;text-align: center;">请上传公司头像</p>
            <input type="file" @change="getFile($event)" >
            <button class="button button-primary button-pill button-small" @click="submit($event)">提交</button>
          </form>
        </div>
        <div style="margin-top: 40px">

          <div style="width: 80%;margin-top: 30px">
            <!--<span class="demonstration" style="color: slategray">岗位属性</span>-->



            属性： <el-cascader
              :options="options"
              v-model="selectedOptions"
              @change="handleChange">
            </el-cascader>
          </div>
          <div style="margin-top: 30px;width: 80%">
            类型：  <el-select v-model="value2" placeholder="请选择">
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled">
            </el-option>
          </el-select>
          </div>
          <div style="width: 80%">
           介绍： <el-input type="textarea" :rows="2" placeholder="要求" v-model="introduce" style="width: 70%;margin-top: 30px" ></el-input>
          </div>
        </div>

        <div style="width: 100%">
          <form style="width: 100%">
            <p style="width: 100%;text-align: center;">详细描述</p>
            <input type="file" @change="getFilee($event)" >
            <button class="button button-primary button-pill button-small" @click="submite($event)">提交</button>
          </form>
        </div>
        <div style="width: 100%">
          <el-button plain style="margin-top: 20px;width: 100px" size="small" @click="register()">发出申请</el-button>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        wid:'',
        oid:'',
        id:'',
        InputPrice:'',
        userTime:'',
        introduce:'',
        file: '',
        filee: '',
        options: [
          {
            value: 'WEB后台',
            label: 'WEB后台',
            children: [
              {value: 'JAVA',
                label: 'JAVA',},
              {value: 'C#',
                label: 'C#',},
              {value: 'PHP',
                label: 'PHP',},
              {value: '其他',
                label: '其他',},
            ],
          },
          { value: 'WEB前端',
            label: 'WEB前端',
            children: [
              {value: 'VUE',
                label: 'VUE',},
              {value: 'HTML',
                label: 'HTML',},
              {value: 'JS',
                label: 'JS',},
              {value: '其他',
                label: '其他',},
            ]},

          {
            value: '移动端',
            label: '移动端',
            children: [
              {value: '微信小程序',
                label: '微信小程序',},
              {value: '微信公众号',
                label: '微信公众号',},


              {value: '支付宝小程序',
                label: '支付宝小程序',},
              {value: 'RN',
                label: 'RN',},
              {value: '其他',
                label: '其他',},
            ],
          },
          { value: '大数据.人工智能',
            label: '大数据.人工智能',
            children: [
              {value: '数据采集',
                label: '数据采集',},
              {value: '数据分析',
                label: '数据分析',},
              {value: '人脸识别',
                label: '人脸识别',},
              {value: '其他',
                label: '其他',},
            ]},
        ],
        selectedOptions: [],
        selectedOptions2: [],
        options2: [{
          value: '长期工',
          label: '长期工',

        },
       {
            value: '短期工',
            label: '短期工',

        }
        ],
        value2: '',
      }
    },
    mounted: function(){

      // var user= JSON.parse(window.sessionStorage.getItem("user"));
      // let r=user.id

   //   this.oid= this.$route.query.mallCode
      //
      // axios.post('/workroom/selectWorkroomProgress',{
      //   tdid:this.oid,
      //   id:this.oid
      // }).then((response) => {
      //
      //   if(response.data!==null){
      //     let ee=response.data
      //     console.log(ee)
      //     var data=[];
      //     let ff=0
      //     for(var c=0;c<ee.length;c++){
      //       var eee=ee[c]
      //       console.log(eee)
      //       if(eee.states==0){
      //         var obj={}
      //         obj.value=eee.id
      //         obj.label=eee.name
      //         data[ff]=obj
      //         ff=ff+1
      //       }
      //
      //     }
      //     this.options2=data
      //     console.log(this.options)
      //   }  else{
      //
      //   }
      // }).catch((response)=>{
      //
      // })
    },
    methods: {

      getFile: function (evente) {
        this.file = event.target.files[0];
        console.log(this.file);
      },
      getFilee: function (event) {
        this.filee = event.target.files[0];
        console.log(this.filee);
      },
      submit: function (event) {
        //阻止元素发生默认的行为
        var _this=this
        event.preventDefault();
        let formData = new FormData();
        console.log(formData)
        formData.append("file", this.file)
        axios.post('/upload/singlefile', formData)
          .then(function (response) {
            alert(response.data);
            console.log(response);
            var a= response.data;
            // var e=a.split("*");
            //console.log(e[1])
            _this.file=a;
            // window.location.reload();
          })
          .catch(function (error) {
            alert("上传失败");
            console.log(error);
            //window.location.reload();
          });
      },
      submite: function (event) {
        var _this=this
        //阻止元素发生默认的行为
        event.preventDefault();
        let formData = new FormData();
        console.log(formData)
        formData.append("file", this.filee)
        axios.post('/upload/singlefile', formData)
          .then(function (response) {
            alert(response.data);
            console.log(response);
            var a= response.data;
            //  var e=a.split("*");
            //console.log(e[1])
            _this.filee=a;
          })
          .catch(function (error) {
            alert("上传失败");
            console.log(error);
            //window.location.reload();
          });
      },
      register(){

        var user= JSON.parse(window.sessionStorage.getItem("user"));
        let r=user.id
        var  selectedOptions=this. selectedOptions.toString()
        axios.post('/user/insertEmploy',{
          wid:r,
          lable:selectedOptions,
          introduce:this.introduce,
          photo:this.file,
          doc:this.filee,
          slable:this.value2,
        }).then((response) => {
          // console.log(response.data.states)
          if(response.data.states==800){
            this.$notify({
              title: '成功',
              message: '申请成功',
              type: 'success',
              duration:2000
            });
            this.$router.replace({
              path: '/RecruitMember',
              }
              )


          }else{
            this.$notify.error({
              title: '错误',
              message: response.data.message,
              type: 'warning',
              duration:0
            });
          }
        }).catch((response)=>{

        })
      }

    },





  }
</script>

<style scoped>

</style>
